<template>
  <div class="dialog-wrapper">
    <el-dialog  :visible.sync="dialogFormVisible">
    <el-form :model="form">
      <el-form-item label="请输入入库件数: " :label-width="formLabelWidth">
        <el-input v-model="form.count" auto-complete="off" class="count"></el-input>
      </el-form-item>
      <el-form-item label="备注: " :label-width="formLabelWidth">
        <el-input v-model="form.comment" auto-complete="off" class="comment" placeholder="入库操作"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogFormVisible = false" class="cancleBtn">取 消</el-button>
      <el-button type="primary" @click="dialogFormVisible = false" @click.native="enterStorage" class="confirm">确 定</el-button>
    </div>
  </el-dialog>  
  </div>
</template>
<script>
import {enterStorage, outStorage} from '@/api/operations'
export default {
  props: {
    id: {
      type: Number,
      default: 0
    }
  },
  data () {
    return {
       dialogFormVisible: false,
        form: {
          count: 0,
          comment: ''
        },
        formLabelWidth: '120px'
    }
  },
  methods: {
    changeDialogFormVisible() {
      this.dialogFormVisible = true
    },
    enterStorage() {
      let _this = this
      async function enterStore(count, comment) {
        await enterStorage({part_id:_this.id, count: count, description: comment})
        _this.$emit('fetchData')
      } 
      enterStore(this.form.count, this.form.comment)
    }

  }
 
}
</script>
<style lang="scss" scoped>
.count{
  width: 80%;
}
.comment{
  width: 80%;
}
.dialog-wrapper /deep/.el-dialog{
  width: 35% !important;
}
.cancleBtn,.confirm{
  width: 70px !important;
  height: 34px !important;
  padding: 7.5px 0;
}
</style>